﻿<%@ Page Language="C#" %>

<%@ Import Namespace="wojilu" %>
<%@ Import Namespace="wojilu.View" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Domain" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>#{softtitle}</title>
<link href="#{path.css}ybb/css/baselist.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/all.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/formdiv.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="#{path.js}ybb/js/jquery.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/control.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/form.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/My97DatePicker/WdatePicker.js?v=#{jsVersion}"></script>
<script type="text/javascript">

	var resizewindow= null;

	window.onresize = function(){
		var h = $(window).height();
		if(resizewindow!=h){
			sizewindow();
			resizewindow=h;
		}
	}

	function sizewindow(){
		var h = $(window).height();
		if(document.getElementById("mainbodybottonauto")){
			$('.managebottonadd').css({height:h-40});
		}
	}
	var advertmain_js_atid_empty = "_{advertmain_js_atid_empty}";
	var advertmain_js_title_empty = "_{advertmain_js_title_empty}";
	var advertmain_js_url_empty = "_{advertmain_js_url_empty}";
	var advertmain_js_url_gotoid = "_{advertmain_js_url_gotoid}";
	var advertmain_js_filename_empty = "_{advertmain_js_filename_empty}";
	var advertmain_js_edit_ok = "_{advertmain_js_edit_ok}";
	var advertmain_js_edit_no = "_{advertmain_js_edit_no}";
	var advertmain_js_add_ok = "_{advertmain_js_add_ok}";
	var advertmain_js_add_no = "_{advertmain_js_add_no}";
	var iframename = "#{iframename}";
	iframename = iframename=='' ? "jerichotabiframe_0" : iframename;
	var addtype = "#{type}";
	$(document).ready(function(){
	    var h = '#{iframeheightwindow}';
		$('.managebottonadd').css({height:h-40});
		var options = {
			beforeSubmit: formverify,
			success:saveResponse,
			resetForm: false
		}
		$('#infosave').submit(function() {
			$(this).ajaxSubmit(options);
			return false;
		});
		if (parent.document.getElementById('centerleft')){
			parent.scrolclear();
		}
	})




	function formverify(formData) {
		var queryString = $.param(formData);
		var get=urlarray(queryString);
		if(get['atid']==0){
			document.infosave.atid.focus();
			alert(advertmain_js_atid_empty);
			return false;
		}
		if(get['title']==''){
			document.infosave.title.focus();
			alert(advertmain_js_title_empty);
			return false;
		}
		if(get['islink']==2){
			if(get['gotoid'].match(/^[1-9][0-9]*$/ig)==null) {
				document.infosave.gotoid.focus();
				alert(advertmain_js_url_gotoid);
				return false;
			}
		}else{
			if(get['url']!=''){
				if(get['url'].match(/^http:\/\/[a-zA-Z\:.0-9-%@#;&?=/_]+$/ig)==null) {
				document.infosave.url.focus();
				alert(advertmain_js_url_empty);
				return false;
			}
			}
		}
		if(get['filename']=='' && (get['atid']==1 || get['atid']==2)) {
			alert(advertmain_js_filename_empty);
			return false;
		}
		parent.windowsdig('Loading', 'iframe:#{load}', '400px', '180px', 'iframe', false);
	}
	function saveResponse(options){
		parent.closeifram();
		if (options=='true'){
			if(parent.frames[iframename].document.getElementById("selectform")){
				parent.frames[iframename].refresh('selectform','selectall','check_all');
			}
			if (addtype=='edit'){
				alert(advertmain_js_edit_ok);
			}else{
				alert(advertmain_js_add_ok);
			}
		}else{
			if (addtype=='edit'){
				alert(advertmain_js_edit_no+"("+options+")");
			}else{
				alert(advertmain_js_add_no+"("+options+")");
			}
			
		}
		if (parent.document.getElementById('centerleft')){
			parent.scrolopen();
		}
		parent.onaletdoc()
	}
	function selectinfo(val){
	    var strhtml1 = '<ul class="addpiclist"><li><a title="_{selectfile_botton}" onclick="javascript:parent.windowsdig(\'_{filemanage_select_title}\',\'iframe:<%=link.to(new wojilu.Web.Controller.Admin.Qycms.PublicController().FileWindow) %>?listfunction=filelist&filetype=img&checkfrom=picshow&getbyid=addsrcpic&fileinputid=filename&maxselect=1&iframename=\'+self.frameElement.getAttribute(\'name\'),\'900px\',\'480px\',\'iframe\')" href="#body"><p><img id="addsrcpic" src="#{path.img}ybb/images/pic.png"></p></a></li></ul><input type="hidden" name="filename" id="filename" size="50" maxlength="50" class="infoInput"/>';
	    var strhtml2 = '<input type="text" name="filename" size="50" id="filename" value="" maxlength="150" class="infoInput"/> <a class="filecheck" onclick="javascript:parent.windowsdig(\'_{filemanage_select_title}\',\'iframe:<%=link.to(new wojilu.Web.Controller.Admin.Qycms.PublicController().FileWindow) %>?listfunction=filelist&filetype=mover&checkfrom=input&getbyid=&fileinputid=filename&maxselect=1&iframename=\'+self.frameElement.getAttribute(\'name\'),\'900px\',\'480px\',\'iframe\')" href="#body">_{selectfile_botton}</a>';
		if (val==1){
			$('#filenamestr').removeClass('trstyle2 displaynone').addClass('trstyle2 displaytrue');
			$("#strhtml").empty();
			$("#strhtml").append(strhtml1);
		}else if(val==2){
			$('#filenamestr').removeClass('trstyle2 displaynone').addClass('trstyle2 displaytrue');
			$("#strhtml").empty();
			$("#strhtml").append(strhtml2);
		}else if(val==3){
			$('#filenamestr').removeClass('trstyle2 displaytrue').addClass('trstyle2 displaynone');
			$("#strhtml").empty();
		}
	}
</script>
</head>

<body>
<%var read = v.data("read") as Advert; %>
<form name="infosave" id="infosave" method="post" action="#{ActionLink}">
<input type="hidden" name="inputclass" value="#{type}" />
<input type="hidden" name="lng" id="lng" value="#{lng}" />
<div id="mainbodybottonauto" class="managebottonadd">
	<div class="maindobycontent">
		<div class="suggestion">
			<span class="sugicon"><span class="strong colorgorning2">_{position_title}</span><span class="colorgorningage">_{advertmain_edit_mess}</span></span>
		</div>
		<div class="manageeditdiv">
			<div class="maneditcontent">
				<table class="formtable">
					<tr class="trstyle2">
						<td class="trtitle011">_{advertmain_add_atid}</td>
						<td class="trtitle02">
							<select size="1" name="atid" id="atid">
								<option value="0">_{advertmain_add_atid_optin}</option>
                                <%List<Advert_Type> list = v.data("list") as List<Advert_Type>; %>
                                <%foreach(var row in list){ %>
								<option <%if(row.Id==read.atid){ %>selected <%} %>value="<%=row.Id %>"><%=row.adtypename %></option>
								<%} %>
							</select>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle011">_{advertmain_add_name}</td>
						<td class="trtitle02">
							<input type="text" name="title" size="60" maxlength="80" value="<%=read.title %>" class="infoInput"/>
							<span class="cautiontitle">_{advertmain_add_name_mess}</span>
						</td>
					</tr>
					<tr class="trstyle2">
						<td width="15%" class="trtitle011">_{advertmain_add_islink}</td>
						<td width="85%" class="trtitle02">
							<input type="radio" value="2" name="islink" onclick="ondisplayother('urllink1','trstyle2 displaytrue','urllink2','trstyle2 displaynone');"<%if(read.islink==0){ %>checked="checked"<%} %>/> _{advertmain_add_islink_2}&nbsp;
							<input type="radio" value="1" name="islink" onclick="ondisplayother('urllink1','trstyle2 displaynone','urllink2','trstyle2 displaytrue')" <%if(read.islink==1){ %>checked="checked"<%} %>/> _{advertmain_add_islink_1}
							<span class="cautiontitle">_{advertmain_add_islink_mess}</span>
						</td>
					</tr>
					<tr class="trstyle2 <%if(read.islink==1){ %>displaynone<%} %>" id="urllink1">
						<td width="15%" class="trtitle011">_{advertmain_add_gotoid}</td>
						<td width="85%" class="trtitle02">
							<input type="text" name="gotoid" id="gotoid" size="10" value="<%=read.gotoid %>" maxlength="10" class="infoInput"/>
							<a class="filecheck" href="#body" onclick="javascript:parent.windowsdig('_{article_doc_add_linkdid}','iframe:<%=link.to(new wojilu.Web.Controller.Admin.Qycms.ArticleController().Article_Window) %>?checkfrom=input&getbyid=gotoid&max=1&inputtext=gotoid&mid=<%=ctx.get("mid") %>&tid=<%=ctx.get("tid") %>&freshid='+Math.random()+'&iframename='+self.frameElement.getAttribute('name'),'800px','400px','iframe');">选择内容</a>
						</td>
					</tr>
					
					<tr class="trstyle2 <%if(read.islink==0){ %>displaynone<%} %>" id="urllink2">
						<td class="trtitle011">_{advertmain_add_url}</td>
						<td class="trtitle02">
							<input type="text" name="url" value="<%=read.url %>" size="60" maxlength="185" class="infoInput"/>
							<span class="cautiontitle">_{advertmain_add_url_mess}</span>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle011">_{advertmain_add_adtype}</td>
						<td class="trtitle02">
							<select size="1" name="adtype" onchange="javascript:selectinfo(this.value)">
                                <%var adlist = v.data("adlist") as List<AdType>; %>
                                <%foreach(var row in adlist){ %>
								<option <%if(row.Id ==read.adtype){ %>selected<%} %> value="<%=row.Id %>"><%=row.Name %></option>
								<%} %>
							</select>
						</td>
					</tr>
					<tr class="trstyle2 <%if(read.adtype==3){ %>displaynone<%} %>" id="filenamestr">
						<td class="trtitle011">_{advertmain_add_filename}</td>
						<td class="trtitle02" id="strhtml">
                            <%if(read.adtype==1){ %>
							<ul class="addpiclist">
                                <%if(read.filename !=""){ %>
								<li id="addsrlipic"><a title="_{remimages_botton}" ondblclick="removerpic('addsrlipic','filename')" href="#body"><p><img id="addsrcpic" src="<%=read.filename %>" width="100" height="100"></p></a></li>
								<%}else{ %>
								<li id="addsrlipic"><a title="_{selectfile_botton}" onclick="javascript:parent.windowsdig('_{filemanage_select_title}','iframe:<%=link.to(new wojilu.Web.Controller.Admin.Qycms.PublicController().FileWindow) %>?listfunction=filelist&filetype=img&checkfrom=picshow&getbyid=addsrlipic&fileinputid=filename&maxselect=1&iframename='+self.frameElement.getAttribute('name'),'900px','480px','iframe')" href="#body"><p><img id="addsrcpic" src="#{path.img}ybb/images/pic.png" width="100" height="100"></p></a></li>
								<%} %>
							</ul>
							<input type="hidden" name="filename" id="filename" value="<%=read.filename %>" size="50" maxlength="50" class="infoInput"/>
							<%}else if(read.adtype==2){ %>
							<input type="text" name="filename" size="50" id="filename" value="<%=read.filename %>" maxlength="150" class="infoInput"/> 
							<a class="filecheck" onclick="javascript:parent.windowsdig('_{filemanage_select_title}','iframe:<%=link.to(new wojilu.Web.Controller.Admin.Qycms.PublicController().FileWindow) %>?listfunction=filelist&filetype=mover&checkfrom=input&getbyid=&fileinputid=filename&maxselect=1&iframename='+self.frameElement.getAttribute('name'),'900px','480px','iframe')" href="#body">_{selectfile_botton}</a>
							<%} %>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{advertmain_text_istime}</td>
						<td class="trtitle02">
							<input type="radio" value="1" name="istime" <%if(read.istime==1){ %>checked="checked"<%} %> onclick="showdiv(1,'#starttimediv|#endtimediv','0|1','trstyle2 displaynone|trstyle2 displaytrue',1,1)"/> _{open_botton_title}&nbsp;
							<input type="radio" value="0" name="istime" <%if(read.istime==0){ %>checked="checked"<%} %> onclick="showdiv(0,'#starttimediv|#endtimediv','0|1','trstyle2 displaynone|trstyle2 displaytrue',1,1)"/> _{close_botton_title}
							<span class="cautiontitle">_{advertmain_text_istime_mess}</span>
						</td>
					</tr>
					<tr class="trstyle2 <%if(read.istime==0){ %>displaynone<%} %>">
						<td class="trtitle01">_{advertmain_add_starttime}</td>
						<td class="trtitle02">
							<input type="text" name="starttime" size="20" maxlength="30" id="starttime" value="<%=read.starttime %>" class="infoInput"/>
							<a class="datetime" onclick="WdatePicker({el:'starttime',isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd'})" href="#body">_{selectdata_botton}</a>
						</td>
					</tr>
					<tr class="trstyle2 <%if(read.istime==0){ %>displaynone<%} %>">
						<td class="trtitle01">_{advertmain_add_endtime}</td>
						<td class="trtitle02">
							<input type="text" name="endtime" size="20" maxlength="30" id="endtime" value="#{read.endtime}" class="infoInput"/>
							<a class="datetime" onclick="WdatePicker({el:'endtime',isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd'})" href="#body">_{selectdata_botton}</a>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{advertmain_add_content}</td>
						<td class="trtitle02"><textarea name="content" id="content" style="width:98%;height:80px;" class="smallInput">#{read.content}</textarea></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<div id="downbotton">
	<div id="subbotton">
        <%var type = v.data("type") as String; %>
        <%if (type == "edit") { %>
		<table width="100%">
			<tr>
				<td id="right"><input type="submit" id="docaddsubmitbotton" name="Submit" value="_{botton_edit}" class="buttonface" /></td>
				<td id="left" class="padding-left5"><input type="button" name="cancel" onClick="javascript:closewindow();" value="_{botton_edit_reset}" class="buttonface" /></td>
			</tr>
		</table>
		<%}else{ %>
		<table width="100%">
			<tr>
				<td id="right"><input type="submit" id="docaddsubmitbotton" name="Submit" value="_{botton_add}" class="buttonface" /></td>
				<td id="left" class="padding-left5"><input type="button" name="cancel" onClick="javascript:closewindow();" value="_{botton_add_reset}" class="buttonface" /></td>
			</tr>
		</table>
		<%} %>
	</div>
</div>
</form>
</body>

</html>